# RaceDB.py

"""
    Displays the Race panel in the main GUI window
"""
import os
import sqlite3

class RaceDB():
    def __init__(self):
        super(RaceDB, self).__init__()

        self.db_name = "./db/RW_Race_DB.sqlite3"

        if(not os.path.isfile(db_name)):
            self.__db_init()

    def __db_init():
        pass

    def __open() :
        self.connection = sqlite3.connect(self.db_name)

    def __close():
        self.connection.close()

    def executeSQL(sql=""):
        if(sql != ""):
            self.__open()
            self.connection.execute(sql)
            self.__close()

    def addUser(user=""):
        if(user != ""):
            if(self.getUser(user) == ""):
                self.executeSQL("INSERT INTO Drivers (name) VALUES (" + user + ")")
            else:
                QtGui.QMessageBox.warning(self,"RocketWheels","Driver already exists.")

    def getUser(user=""):
        if(user != ""):
            pass

    def addCar(car=""):
        pass

    def getUsers():
        pass

    def getCars():
        pass
